<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.util.Map"%> 
<%@ page import="java.util.List"%>
<%@ page import="java.util.Iterator"%>   
<%@ page import="jt.classic.app.dbtx.DbtxManager" %>
<%@ page import="org.limp.mine.DateTrimmer"%>
<%@ page import="org.limp.mine.StringTool"%>
<% 
    String context = jt.classic.system.ISystem.getContextPath();
    
    Map calendarMap = (Map)request.getAttribute("calendarMap");
    
    String year = StringTool.checkString(request.getAttribute("year"));
    String month = StringTool.checkString(request.getAttribute("month"));
    
    String startDate = StringTool.checkString(request.getAttribute("startDate"));
    String endDate = StringTool.checkString(request.getAttribute("endDate"));
%>        
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>日程管理</title>
</head>
<jsp:include page="../head.jsp"></jsp:include>
<link rel="StyleSheet" href="<%=context %>/app/dbtx/css/calendar.css" type="text/css" />
<script>
    /*当前显示日历年*/
    var nowYear = <%=year%>;
    /*当前显示日历月*/
    var nowMonth = <%=month%>;
    /*当前日历开始时间*/
    var startDate = "<%=startDate%>";
    /*当前日历结束时间*/
    var endDate = "<%=endDate%>";
</script>
<script type="text/javascript" src="<%=context%>/app/grrz/js/menu.js"></script>
<script type="text/javascript" src="<%=context %>/app/dbtx/js/mdate.js"></script>
<script type="text/javascript" src="<%=context %>/app/dbtx/js/calendar.js"></script>

<script src="<%=context %>/resources/dhtmlx/codebase/dhtmlxcommon.js"></script>
<script src="<%=context %>/resources/dhtmlx/codebase/dhtmlxcontainer.js"></script>
<link rel="stylesheet" type="text/css" href="<%=context %>/resources/dhtmlx/codebase/dhtmlxwindows.css">
<link rel="stylesheet" type="text/css" href="<%=context %>/resources/dhtmlx/codebase/skins/dhtmlxwindows_dhx_skyblue.css">
<script src="<%=context %>/resources/dhtmlx/codebase/dhtmlxwindows.js"></script>

<%
    if(calendarMap != null && !calendarMap.isEmpty()){
       Iterator iter = calendarMap.keySet().iterator();
       while(iter.hasNext()){
           String key = (String)iter.next();
           List infoList = (List)calendarMap.get(key);
           StringBuffer sbuffer = new StringBuffer();
           for(int i=0;i<4;i++){
        	   if(i < infoList.size()){
	        	   Map info = (Map)infoList.get(i);
	        	   String id = (String)info.get("ID");
	        	   String title = (String)info.get("TITLE");
	        	   String type = (String)info.get("TYPE");
	        	   String createTime = (String)info.get("CREATETIME");
	        	   String sTime = DateTrimmer.getYMDHM_LBL((String)info.get("STIME"));
	        	   String eTime = DateTrimmer.getYMDHM_LBL((String)info.get("ETIME"));
	        	   
	        	   String timeLabel = sTime + "~" + eTime;
	        	   
	        	   /*开始时间和结束时间在一天内*/
	        	   if(DateTrimmer.getYMD_LBL((String)info.get("STIME")).equals(DateTrimmer.getYMD_LBL((String)info.get("ETIME")))){
	        		   /*开始时间和结束时间只显示小时和分钟*/
	        		   timeLabel = DateTrimmer.getYMDHMS_LBL((String)info.get("STIME")).substring(11, 16) + "~" + DateTrimmer.getYMDHMS_LBL((String)info.get("ETIME")).substring(11, 16);   
	        	   }
	        	   
	        	   String createTimeLabel = DateTrimmer.getYMD_LBL(createTime);
	        	   String typeLabel = DbtxManager.getTypeName(type);
	        	   
	        	   if(type.equals("normal")){
	        		   sbuffer.append("<div class=\"divn\" style=\"width:70px;\"><a href=\"javascript:void(0);\" onclick=\"javascript:handleEdit(\\'"+id+"\\', \\'"+createTime+"\\', \\'"+createTimeLabel+"\\');\" title=\""+title+","+timeLabel+"\">"+title+"</a></div>");
	        	   }else{
	        		   sbuffer.append("<div class=\"divn\" style=\"width:70px;\"><a href=\"javascript:void(0);\" title=\"["+typeLabel+"] "+title+"\">"+title+"</a></div>");
	        	   }
        	   }else{
        		   sbuffer.append("<div class=\"divn\" style=\"width:70px;\">&nbsp;</div>");
        	   }
           }
           out.println("<script>mymap.put('"+key+"','" + sbuffer.toString() + "');</script>");
           out.println("<script>arrArtdate.push('" + key + "');</script>");
       }
    }
%>
<body onload="javascript:init();" leftmargin="0" topmargin="0">
<form name="form1" method="post" action="">
<br/>
<table cellspacing="0" cellpadding="0" width="98%" style="border-collapse: collapse;border: 1px; padding: 1px;" align="center">
<tr height="20">
<td align="left" style="cursor: hand; font-size:9pt;" title="上一年">&nbsp;<a href="javascript:void(0);" onclick="javascript:pushBtm('YU')">上一年</a></td>
<td align="left" style="cursor: hand; font-size:9pt" title="上一月">&nbsp;<a href="javascript:void(0);" onclick="javascript:pushBtm('MU')">上一月</a></td>
<td align="center" nowrap="nowrap" style="font-size:9pt"><b><span id="YMBG"></span>&nbsp;<span id="GZ"></span></b></td>
<td align="right" style="cursor: hand; font-size:9pt" title="下一月"><a href="javascript:void(0);" onclick="javascript:pushBtm('MD')">下一月</a>&nbsp;</td>
<td align="right" style="cursor: hand; font-size:9pt" title="下一年"><a href="javascript:void(0);" onclick="javascript:pushBtm('YD')">下一年</a>&nbsp;</td>
</tr>
<tr><td colspan="6">
<div id="ttdiv" align="center"></div>
</td></tr>
<tr><td colspan="6" height="1"></td></tr>
</table>
<!--右键菜单-->
<div id="bmenu"></div>
</form>
</body>
</html>
<script>
parent.resizeFrame(800, 950);
</script>